home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / QuickTime / Programming Stuff / Sample Code / Music Architecture / Mixed Bag / BigEasy / BigEasyControls.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-11  |  15.7 KB  |  832 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        BigEasyControls.c
  3.  
  4.     Copyright:    © 1990-1991, 1994 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     This file is used in these builds: Warhol
  7.  
  8.     Change History (most recent first):
  9.  
  10.         <10>    11-10-94    dvb        
  11.          <9>     6/10/94    dvb        nil control list behaves better.
  12.          <8>     4/13/92    dvb        Minor bugs (empty controllist, &c)
  13.          <7>      4/3/92    dvb        New calls.
  14.          <6>     5/28/91    JB        Added prototypes for BigEasy Proc Ptrs
  15.          <5>     5/22/91    PH        new style prototypes
  16.          <4>     4/25/91    JB        Changing to new THINK_C interface files
  17.          <3>     12/5/90    GW        Fix dispose easycontrol
  18.          <2>    11/17/90    dvb        Return unprocessed key-actions
  19.         <1>        11/17/90    dvb        New again after 1st CD!
  20.  
  21.     To Do:
  22. */
  23.  
  24. /*
  25.   * file: BigEasyControls.c
  26.   *
  27.   * started 25 May 1990 12:07:24 Friday at 310 Nobel
  28.   * 
  29.   * david van brink
  30.   *
  31.   */
  32.  
  33. /************************************
  34. * Inclusions
  35. ************************************/
  36.  
  37. #include <Memory.h>
  38. #include <QuickDraw.h>
  39. #include <Events.h>
  40.  
  41. #define privateEasyControls
  42. #include "BigEasy2.h"
  43. #include "BigEasyGrafish.h"
  44. #include "BigEasyTextish.h"
  45. #include "BigEasyControls.h"
  46.  
  47.  
  48. /************************************
  49. * Globals
  50. ************************************/
  51.  
  52. static short defaultColors[6] =
  53.     {
  54.     0,
  55.     PackColor555(46035,46035,46035),
  56.     PackColor555(25535,65535,25535),
  57.     PackColor555(24000,0,0),
  58.     0,
  59.     0
  60.     };
  61.  
  62. /************************************
  63. * Prototypes
  64. ************************************/
  65. static void SelectEasyControl(easyControl ech, easyControlList list);
  66. static void UnhighlightSelection(easyControlList list);
  67. static void WalkDrawEasyControlList(easyControlList list,long,long);
  68. static void WalkInvalEasyControlList(easyControlList list,long,long);
  69. static short GetControlNumber(easyControl ech);
  70.  
  71. static void SetListText(easyControlList listH);
  72.  
  73. /************************************
  74. * Routines
  75. ************************************/
  76. easyControl NewEasyControl(easyControlType *type,Rect *r, long variation, void *style,
  77.         long refcon,long id,long value,easyControlList list)
  78. /*
  79.   * Make a new handle for an easy control, and call the
  80.   * init routine for that control. Then, add it to the
  81.   * list passed in.
  82.   */
  83.     {
  84.     easyControl ech;
  85.     register easyControlPtr ec;
  86.     register easyControl w;
  87.     easyControlListPtr l;
  88.  
  89.     ech = (easyControl)NewHandle(sizeof(easyControlRecord));
  90.     FailNil(ech);
  91.  
  92.     HLock((Handle)ech);
  93.     ec = *ech;
  94.  
  95.     ec->next = nil;
  96.     ec->list = list;
  97.     l = *list;
  98.     w = l->firstControl;
  99.     if(!w)
  100.         {
  101.         ec->prev = nil;
  102.         l->firstControl = ech;
  103.         }
  104.     else
  105.         {
  106.         while((**w).next)
  107.             w = (**w).next;
  108.         (**w).next = ech;
  109.         ec->prev = w;
  110.         }
  111.  
  112.     ec->type = type;
  113.     ec->rect = *r;
  114.     ec->flags = easyControlActive;
  115.     ec->refcon = refcon;
  116.     ec->id = id;
  117.     ec->variation = variation;
  118.     ec->value = value;
  119.     ec->style = style;
  120.     ec->state = nil;
  121.  
  122.     ec->color[0] = defaultColors[0];
  123.     ec->color[1] = defaultColors[1];
  124.     ec->color[2] = defaultColors[2];
  125.     ec->color[3] = defaultColors[3];
  126.     ec->color[4] = defaultColors[4];
  127.     ec->color[5] = defaultColors[5];
  128.  
  129.     ec->actionProc = nil;
  130.     ec->initActionProc = nil;
  131.     ec->doneActionProc = nil;
  132.     ec->valueProc = nil;
  133. /*    ec->keyProc = nil; */
  134.  
  135.     ec->low = 0;
  136.     ec->high = 100;
  137.  
  138.     SetListText(list);
  139.  
  140.     (*type->newProc)(ec);
  141.  
  142.     HUnlock((Handle)ech);
  143.     return ech;
  144.     }
  145.  
  146. void DisposeEasyControl(easyControl ech, easyControlList list)
  147. /*
  148.   * remove a control from the list passed
  149.   */
  150.     {
  151.     register easyControl *w;
  152.     register easyControlPtr ec;
  153.     register easyControlListPtr l;
  154.     easyControl last;
  155.  
  156.     l = *list;
  157.     last = nil;
  158.     ec = *ech;
  159.     w = &l->firstControl;
  160.  
  161.     while(*w)
  162.         {
  163.         if(*w == ech)
  164.             {
  165.             *w = ec->next;
  166.             if (*w != nil)    /* Make sure its not nil - GW */
  167.                 (**(ec->next)).prev = last;
  168.             goto goHome;
  169.             }
  170.         else
  171.             {
  172.             last = *w;
  173.             w = &(***w).next;
  174.             }
  175.         }
  176. goHome:;
  177.     DisposHandle((Handle)ech);
  178.     }
  179.  
  180. void DisposeEasyControlList(easyControlList list)
  181.     {
  182.     register easyControl w,n;
  183.  
  184.     w = (**list).firstControl;
  185.     while(w)
  186.         {
  187.         n = (**w).next;
  188.         DisposeEasyControl(w,list);
  189.         w = n;
  190.         }
  191.     DisposHandle((Handle)list);
  192.     }
  193.  
  194. easyControlList NewEasyControlList(WindowPtr w,long refcon)
  195.     {
  196.     easyControlList listH;
  197.     easyControlListPtr list;
  198.  
  199.     listH = (easyControlList)NewHandle(sizeof(easyControlListRecord));
  200.     list = *listH;
  201.     list->firstControl = nil;
  202.     list->selectedControl = nil;
  203.     list->nextSelectedControl = nil;
  204.     list->ownerWindow = w;
  205.     list->refcon = refcon;
  206.     list->textFont = 3;    /* geneva */
  207.     list->textSize = 9;
  208.     list->textFace = 0;
  209.     list->nextIdle = 0;
  210.     list->ticksPerIdle = 30;
  211.  
  212.     return listH;
  213.     }
  214.  
  215. void SetListText(easyControlList listH)
  216.     {
  217.     TextFont((**listH).textFont);
  218.     TextFace((**listH).textFace);
  219.     TextSize((**listH).textSize);
  220.     }
  221.  
  222. void KeyEasyControlList(easyControlList listH,short key,short mods,controlClickResult *ccr)
  223. /*
  224.   * Pass a keypress to the currently
  225.   * selected control. we swipe "tab"s
  226.   * to skip from control to control, and
  227.   * "esc" to say "no control selected".
  228.   */
  229.     {
  230.     register easyControl ech;
  231.     register easyControlPtr ec;
  232.     register easyControlListPtr list;
  233.     short listHState;
  234.     Boolean tookKey;
  235.  
  236.     listHState = HGetState((Handle)listH);
  237.     HLock((Handle)listH);
  238.     list = *listH;
  239.  
  240.     if(ccr)
  241.         {
  242.         ccr->whichControl = nil;
  243.         ccr->tracked = false;
  244.         ccr->value = 0;
  245.         ccr->refcon = 0;
  246.         ccr->id = 0;
  247.         }
  248.  
  249.     ech = list->selectedControl;
  250.     if(key == '\t')
  251.         {
  252.     nextEch:
  253.         if(ech)
  254.             {
  255.             if(mods & shiftKey)
  256.                 ech = (**ech).prev;
  257.             else
  258.                 ech =(**ech).next;
  259.             }
  260.         else
  261.             {
  262.             ech = list->firstControl;
  263.             if(mods & shiftKey && ech)
  264.                 while((**ech).next)
  265.                     ech = (**ech).next;
  266.             }
  267.         if(list->nextSelectedControl)
  268.             {
  269.             ech = list->nextSelectedControl;
  270.             list->nextSelectedControl = nil;
  271.             }
  272.  
  273.         if(ech && !(**ech).type->keyProc)        /* if its got no keyproc, it doesn't do keypresses */
  274.             goto nextEch;
  275.         SelectEasyControl(ech,listH);
  276.         }
  277.     else if(key == 27)            /* the escape key */
  278.         {
  279.         SelectEasyControl(nil,listH);
  280.         list->nextSelectedControl = ech;
  281.         }
  282.     else
  283.         {
  284.         if(ech)
  285.             {
  286.             HLock((Handle)ech);
  287.             ec = *ech;
  288.             (*ec->type->keyProc)(ec,key,mods,&tookKey);
  289.  
  290.             if(ccr)
  291.                 {
  292.                 ccr->whichControl = ech;
  293.                 ccr->tracked = tookKey;
  294.                 ccr->value = ec->value;
  295.                 ccr->refcon = ec->refcon;
  296.                 ccr->id = ec->id;
  297.                 }
  298.  
  299.             HUnlock((Handle)ech);
  300.  
  301.             UnhighlightSelection(listH);            /* and forestall the next idle-blink for a while */
  302.             }
  303.         }
  304.     HSetState((Handle)listH,listHState);
  305.     }
  306.  
  307. short GetControlNumber(register easyControl ech)
  308. /*
  309.   * return the position in whatever list owns this control
  310.   */
  311.     {
  312.     short n;
  313.  
  314.     n = 1;
  315.     while( (**ech).prev)
  316.         {
  317.         n++;
  318.         ech = (**ech).prev;
  319.         }
  320.     return n;
  321.     }
  322.  
  323.  
  324. void UnhighlightSelection(easyControlList listH)
  325. /*
  326.   * if there's a selected control,
  327.   * put it in the unhighlighted phase
  328.   */
  329.     {
  330.     register easyControl ech;
  331.     register easyControlPtr ec;
  332.     easyControlListPtr list;
  333.     short listHState;
  334.  
  335.     listHState = HGetState((Handle)listH);
  336.     HLock((Handle)listH);
  337.     list = *listH;
  338.  
  339.     ech = list->selectedControl;
  340.     if(ech)
  341.         {
  342.         list->nextIdle = TickCount()+list->ticksPerIdle;        /* reset the idling phase to normal    */
  343.         HLock((Handle)ech);
  344.         ec = *ech;
  345.         list->idleRef = 0;
  346.         SetPort((*ec->list)->ownerWindow);
  347.         (*ec->type->idleProc)(ec,&list->idleRef);
  348.         HUnlock((Handle)ech);
  349.         }
  350.     HSetState((Handle)listH,listHState);
  351.     }
  352.  
  353. easyControl ClickEasyControlList(easyControlList listH,Point p,
  354.         controlClickResult *ccr,short mods)
  355.     {
  356.     register easyControl w;
  357.     register easyControlPtr ec;
  358.     easyControlListPtr list;
  359.     short trackResult;
  360.     short whichControl;
  361.     short listHState;
  362.  
  363.     listHState = HGetState((Handle)listH);
  364.     HLock((Handle)listH);
  365.  
  366.     list = *listH;
  367.  
  368.     w = list->firstControl;
  369.     whichControl = 0;
  370.  
  371.     if(ccr)
  372.         {
  373.         ccr->whichControl = nil;
  374.         ccr->tracked = false;
  375.         ccr->value = 0;
  376.         ccr->refcon = 0;
  377.         ccr->id = 0;
  378.         }
  379.  
  380.     while(w)
  381.         {
  382.         whichControl++;
  383.         if(PtInRect(p,&(**w).rect) && (**w).type->trackProc)        /* in rect and mouse sensitive */
  384.             {
  385.             SelectEasyControl(nil,listH);
  386.             HLock((Handle)w);
  387.             ec = *w;
  388.             ec->flags |= easyControlTracking;
  389.             if(ec->type->keyProc)                            /* never select keyless control */
  390.                 list->nextSelectedControl = w;
  391.             trackResult = 0;
  392.             ec->flags |= easyControlSetValue;
  393.             (*ec->type->trackProc)(ec,p,&trackResult,mods);
  394.             if(trackResult && ec->valueProc)
  395.                 (*ec->valueProc)(w);
  396.             ec->flags &= ~easyControlSetValue;
  397.  
  398.             if(ccr)
  399.                 {
  400.                 ccr->whichControl = w;
  401.                 ccr->tracked = true;
  402.                 ccr->value = ec->value;
  403.                 ccr->refcon = ec->refcon;
  404.                 ccr->id = ec->id;
  405.                 }
  406.  
  407.             ec->flags &= ~easyControlTracking;
  408.             (*ec->type->drawValueProc)(ec);
  409.             HUnlock((Handle)w);
  410.             goto goHome;
  411.             }
  412.         else
  413.             w = (**w).next;
  414.         }
  415. goHome:;
  416.     HSetState((Handle)listH,listHState);
  417.     return w;
  418.     }
  419.  
  420. void DrawEasyControlList(register easyControlList list)
  421.     {
  422.     WalkDrawEasyControlList(list,~0,0);
  423.     }
  424.  
  425. void DeactivateEasyControlList(easyControlList list)
  426. /*
  427.   * A window should call this when it
  428.   * becomes un-frontmost
  429.   */
  430.     {
  431.     WalkDrawEasyControlList(list,~0,easyControlBack);
  432.     }
  433.  
  434. void ActivateEasyControlList(easyControlList list)
  435. /*
  436.   * A window should call this when it
  437.   * becomes frontmost
  438.   */
  439.     {
  440.     WalkInvalEasyControlList(list,~easyControlBack,0);
  441.     }
  442.  
  443.  
  444. void WalkDrawEasyControlList(easyControlList listH,long and,long or)
  445. /*
  446.   * The gut routine of Draw, Activate, and DeactivateEasyControlList
  447.   */
  448.     {
  449.     register easyControlPtr ec;
  450.     register easyControl w;
  451.     register easyControlListPtr list;
  452.     short listHState;
  453.     GrafPtr oldPort;
  454.  
  455.     if(!listH)
  456.         goto goHome;
  457.  
  458.     GetPort(&oldPort);
  459.  
  460.     listHState = HGetState((Handle)listH);
  461.     HLock((Handle)listH);
  462.  
  463.     list = *listH;
  464.  
  465.     SetPort(list->ownerWindow);
  466.  
  467.     SetListText(listH);
  468.  
  469.     w = list->firstControl;
  470.     while (w)
  471.         {
  472.         HLock((Handle)w);
  473.         ec = *w;
  474.         ec->flags &= and;
  475.         ec->flags |= or;
  476.         (*ec->type->drawProc)(ec);
  477.         ValidRect(&ec->rect);
  478.         HUnlock((Handle)w);
  479.         w = ec->next;
  480.         }
  481.     HSetState((Handle)listH,listHState);
  482.  
  483.     SetPort(oldPort);
  484. goHome:;
  485.     }
  486.  
  487.  
  488. void WalkInvalEasyControlList(easyControlList listH,long and,long or)
  489. /*
  490.   * The gut routine of Draw, Activate, and DeactivateEasyControlList
  491.   */
  492.     {
  493.     register easyControlPtr ec;
  494.     register easyControl w;
  495.     register easyControlListPtr list;
  496.     short listHState;
  497.  
  498.     listHState = HGetState((Handle)listH);
  499.     HLock((Handle)listH);
  500.  
  501.     list = *listH;
  502.  
  503.     SetPort(list->ownerWindow);
  504.     w = list->firstControl;
  505.     while (w)
  506.         {
  507.         HLock((Handle)w);
  508.         ec = *w;
  509.         ec->flags &= and;
  510.         ec->flags |= or;
  511.         InvalRect(&ec->rect);
  512.         HUnlock((Handle)w);
  513.         w = ec->next;
  514.         }
  515.     HSetState((Handle)listH,listHState);
  516.     }
  517.  
  518.  
  519.  
  520. void IdleEasyControlList(register easyControlList listH)
  521.     {
  522.     register easyControl ech;
  523.     easyControlPtr ec;
  524.     register easyControlListPtr list;
  525.     long t;
  526.     short listHState;
  527.  
  528.     listHState = HGetState((Handle)listH);
  529.     HLock((Handle)listH);
  530.     list = *listH;
  531.  
  532.     ech = list->selectedControl;
  533.     if(ech)
  534.         {
  535.         t = TickCount();
  536.         if(t > list->nextIdle)
  537.             {
  538.             list->nextIdle = t+list->ticksPerIdle;
  539.             list->idleRef++;
  540.             HLock((Handle)ech);
  541.             ec = *ech;
  542.             SetPort((*ec->list)->ownerWindow);
  543.             (*ec->type->idleProc)(ec,&list->idleRef);
  544.             HUnlock((Handle)ech);
  545.             }
  546.         }
  547.     HSetState((Handle)listH,listHState);
  548.     }
  549.  
  550. void SetEasyControlValue(register easyControl ech,long v)
  551.     {
  552.     register easyControlPtr ec;
  553.     becSetValueProcPtr svp;
  554.  
  555.     HLock((Handle)ech);
  556.     ec = *ech;
  557.     SetPort((**ec->list).ownerWindow);
  558.     svp = ec->type->setValueProc;
  559.     if(svp)
  560.         (*svp)(ec,v);
  561.     else
  562.         ec->value = v;
  563.     ec->flags |= easyControlSetValue;
  564.     SetListText(ec->list);
  565.     (*ec->type->drawValueProc)(ec);
  566.     ec->flags &= ~easyControlSetValue;
  567.     HUnlock((Handle)ech);
  568.     }
  569.  
  570. long GetEasyControlValue(easyControl ech)
  571.     {
  572.     return (**ech).value;
  573.     }
  574.  
  575. long GetEasyControlRefcon(easyControl ech)
  576.     {
  577.     return (**ech).refcon;
  578.     }
  579.  
  580. long GetEasyControlID(easyControl ech)
  581.     {
  582.     return (**ech).id;
  583.     }
  584.  
  585.  
  586.  
  587. void SetEasyControlRange(easyControl ech,long l,long h)
  588.     {
  589.     register easyControlPtr ec;
  590.  
  591.     ec = *ech;
  592.     ec->low = l;
  593.     ec->high = h;
  594.     }
  595.  
  596. void SetEasyControlValueProc(easyControl ech,becValueProcPtr proc)
  597.     {
  598.     register easyControlPtr ec;
  599.  
  600.     ec = *ech;
  601.     ec->valueProc = proc;
  602.     }
  603.  
  604. void SetEasyControlActionProc(easyControl ech,becActionProcPtr proc)
  605.     {
  606.     register easyControlPtr ec;
  607.  
  608.     ec = *ech;
  609.     ec->actionProc = proc;
  610.     }
  611.  
  612. void SetEasyControlInitActionProc(easyControl ech,becInitActionProcPtr proc)
  613.     {
  614.     register easyControlPtr ec;
  615.  
  616.     ec = *ech;
  617.     ec->initActionProc = proc;
  618.     }
  619.  
  620. void SetEasyControlDoneActionProc(easyControl ech,becDoneActionProcPtr proc)
  621.     {
  622.     register easyControlPtr ec;
  623.  
  624.     ec = *ech;
  625.     ec->doneActionProc = proc;
  626.     }
  627.  
  628. void GetEasyControlColors(easyControl ech,register short *colors)
  629.     {
  630.     register short i;
  631.     register short *src;
  632.  
  633.     if(ech)
  634.         src = &(**ech).color[0];
  635.     else
  636.         src = &defaultColors[0];
  637.     for(i = 5; i>=0; i--)
  638.         *colors++ = *src++;
  639.     }
  640.  
  641. void SetEasyControlColors(easyControl ech,register short *colors)
  642.     {
  643.     register short i;
  644.     register short *dst;
  645.  
  646.     if(ech)
  647.         dst = &(**ech).color[0];
  648.     else
  649.         dst = &defaultColors[0];
  650.     for(i = 5; i>=0; i--)
  651.         *dst++ = *colors++;
  652.     }
  653.  
  654.  
  655. void SelectEasyControl(easyControl ech,easyControlList listH)
  656. /*
  657.   * Unselect the current one (if any)
  658.   * and start the new one blinking.
  659.   */
  660.     {
  661.     register easyControlListPtr list;
  662.     short listHState;
  663.  
  664.     listHState = HGetState((Handle)listH);
  665.     HLock((Handle)listH);
  666.     list = *listH;
  667.  
  668.     list->idleRef = 0;
  669.     UnhighlightSelection(listH);
  670.     list->selectedControl = ech;
  671.     list->nextIdle = 0;
  672.     IdleEasyControlList(listH);
  673.  
  674.     HSetState((Handle)listH,listHState);
  675.     }
  676.  
  677. void GetEasyControlRect(easyControl ech,Rect *r)
  678. /*
  679.   * Return the current bounds of the control
  680.   */
  681.     {
  682.     *r = (**ech).rect;
  683.     }
  684.  
  685. void SetEasyControlRect(easyControl ech,Rect *r)
  686. /*
  687.   * Move the control to the newly specified rectangle
  688.   */
  689.     {
  690.     register easyControlPtr ec;
  691.  
  692.     HLock((Handle)ech);
  693.     ec = *ech;
  694.     SetPort((*ec->list)->ownerWindow);
  695.     InvalRect(&ec->rect);
  696.     ec->rect = *r;
  697.     ec->flags |= easyControlMoved;
  698.     InvalRect(&ec->rect);
  699.     HUnlock((Handle)ech);
  700.     }
  701.  
  702. unsigned short Replicate555(register unsigned short x)
  703.     {
  704.     x &= 0x001F;
  705.     return (x<<11) | (x<<6) | (x<<1) | (x>>4);
  706.     }
  707.  
  708. void Color555(register short x,register RGBColor *c)
  709.     {
  710.     c->red = Replicate555(x>>10);
  711.     c->green = Replicate555(x>>5);
  712.     c->blue = Replicate555(x);
  713.     }
  714.  
  715. void Fore555(register short x)
  716.     {
  717.     RGBColor c;
  718.  
  719.     Color555(x,&c);
  720.     RGBForeColor(&c);
  721.     RGBBackColor(&c);
  722.     }
  723.  
  724. #define kGrade 24000
  725. static long PinAdd(long,long);
  726. static long PinAdd(register long a,register long b)
  727.     {
  728.     a+= b;
  729.     if(a > 65535)
  730.         a = 65535;
  731.     else if(a < 0)
  732.         a = 0;
  733.     return a;
  734.     }
  735.  
  736. void Fore555Light(register short x)
  737.     {
  738.     RGBColor c;
  739.  
  740.     Color555(x,&c);
  741.     c.red = PinAdd(c.red,kGrade);
  742.     c.green = PinAdd(c.green,kGrade);
  743.     c.blue = PinAdd(c.blue,kGrade);
  744. /*
  745.     c.green = (c.green + 65535L)>>1;
  746.     c.blue = (c.blue + 65535L)>>1;*/
  747.     RGBForeColor(&c);
  748.     }
  749.  
  750. void Fore555Dark(register short x)
  751.     {
  752.     RGBColor c;
  753.  
  754.     Color555(x,&c);
  755.     c.red = PinAdd(c.red,-kGrade);
  756.     c.green = PinAdd(c.green,-kGrade);
  757.     c.blue = PinAdd(c.blue,-kGrade);
  758. /*    c.red = c.red >> 1;
  759.     c.green = c.green >> 1;
  760.     c.blue = c.blue >> 1;*/
  761.     RGBForeColor(&c);
  762.     }
  763.  
  764. #define kCCEdge 10000
  765. void Fore555Contrast(register short x)
  766. /*
  767.   * Make a color that contrasts well with
  768.   * the passed color: invert if close to a
  769.   * side of the color cube, or shift by 32768
  770.   */
  771.     {
  772.     RGBColor c;
  773.  
  774.     Color555(x,&c);
  775.     if(c.red < kCCEdge || c.red > (65535-kCCEdge) ||
  776.             c.green < kCCEdge || c.green > (65535-kCCEdge) ||
  777.             c.blue < kCCEdge || c.blue > (65535-kCCEdge) )
  778.         {
  779.         c.red = ~c.red;
  780.         c.green = ~c.green;
  781.         c.blue = ~c.blue;
  782.         }
  783.     else
  784.         {
  785.         c.red += 32768;
  786.         c.green += 32768;
  787.         c.blue += 32768;
  788.         }
  789.     RGBForeColor(&c);
  790.     }
  791.  
  792. void RaisedRect(register Rect *r,register short x)
  793. /*
  794.   * Draw rectangle r with a 1 pixel highlight
  795.   * to raise it off the screen
  796.   */
  797.     {
  798.     Fore555(x);
  799.     if( ((r->right - r->left) <= 2) || ((r->bottom - r->top) <= 2) )
  800.         PaintRect(r);
  801.     else
  802.         {
  803.         PenSize(1,1);
  804.         PaintRect(r);
  805.         Fore555Light(x);
  806.         MoveTo(r->left,r->bottom-1);
  807.         LineTo(r->left,r->top);
  808.         LineTo(r->right-1,r->top);
  809.         Fore555Dark(x);
  810.         LineTo(r->right-1,r->bottom-1);
  811.         LineTo(r->left,r->bottom-1);
  812.         }
  813.     }
  814.  
  815. void LoweredRect(Rect *r,register short x)
  816. /*
  817.   * Draw rectangle r with a 1 pixel highlight
  818.   * to raise it off the screen
  819.   */
  820.     {
  821.     PenSize(1,1);
  822.     Fore555(x);
  823.     PaintRect(r);
  824.     Fore555Dark(x);
  825.     MoveTo(r->left,r->bottom-1);
  826.     LineTo(r->left,r->top);
  827.     LineTo(r->right-1,r->top);
  828.     Fore555Light(x);
  829.     LineTo(r->right-1,r->bottom-1);
  830.     LineTo(r->left,r->bottom-1);
  831.     }
  832.